//
//  InstructorCell.m
//  Courses
//
//  Created by xxx on 15/1/9.
//  Copyright (c) 2015年 wtf. All rights reserved.
//

#import "InstructorCell.h"
#import "UIImageView+WebCache.h"
#import "UILabel+AutoSize.h"

@implementation InstructorCell
{
    UIImageView *_imgViewAvatar;
    
    UILabel *_lblTeacherTitle;
    UILabel *_lblTeacherName;
    UILabel *_lblTeacherdescShort;
}

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (!self) return self;
    
    self.backgroundColor = nil;
    self.clipsToBounds = YES;
    self.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    
    _imgViewAvatar = [[UIImageView alloc] initWithFrame:AutoRectMake(20, 10, 60, 60, WTFAutoLayoutTypeRaw)];
    _imgViewAvatar.layer.cornerRadius = 30;
    _imgViewAvatar.contentMode = UIViewContentModeScaleAspectFill;
    _imgViewAvatar.clipsToBounds = YES;
    [self.contentView addSubview:_imgViewAvatar];
    
    _lblTeacherTitle = [[UILabel alloc] initWithFrame:AutoRectMake(RevFloat(100), 10, 100, 20, WTFAutoLayoutTypeBar)];
    _lblTeacherTitle.font = [UIFont fontWithName:nil size:FONT_SIZE_TITLE];
    [self.contentView addSubview:_lblTeacherTitle];
    
    _lblTeacherName = [[UILabel alloc] initWithFrame:AutoRectMake(200, 10, 100, 20, WTFAutoLayoutTypeBar)];
    _lblTeacherName.font = [UIFont fontWithName:nil size:FONT_SIZE_TITLE];
    [self.contentView addSubview:_lblTeacherName];
    
    _lblTeacherdescShort = [[UILabel alloc] initWithFrame:AutoRectMake(RevFloat(100), 35, 200, 40, WTFAutoLayoutTypeBar)];
    _lblTeacherdescShort.font = [UIFont fontWithName:nil size:FONT_SIZE_CONTENT];
    [self.contentView addSubview:_lblTeacherdescShort];
    
    return self;
}

- (void)setTeacher:(Teacher *)teacher
{
    [_imgViewAvatar sd_setImageWithURL:[NSURL URLWithString:teacher.TeacherHeadPhotoUrl]];
    
    _lblTeacherTitle.text = teacher.TeacherTitle;
    _lblTeacherName.text = teacher.TeacherName;
    _lblTeacherdescShort.text = teacher.TeacherdescShort;
    _lblTeacherdescShort.numberOfLines = 3;
    _lblTeacherdescShort.lineBreakMode = NSLineBreakByCharWrapping;
}

@end
